﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace T.FAS.Runtime.ScheduleJob.SPI
{
    [Serializable]
    public class ScheduleJobInstance
    {
        public ScheduleJobInstance()
        {
            ID = Guid.NewGuid().ToString();
        }
        public string ID { get; set; }
        public string ScheduleJobID { get; set; }
        /// <summary>
        /// 计划任务元数据，订阅类的计划任务转化为该结构，不需要通过元数据缓存服务进行元数据定义的获取
        /// </summary>
        public Metadata.Entity.ScheduleJob.ScheduleJob ScheduleJobMetadata { get; set; }
        public ScheduleJobDataMap Data { get; set; }

        public void BuildIdentity()
        {
            var content = ScheduleJobID + JsonConvert.SerializeObject(this.Data);
            this.ID = ScheduleJobRTPUtil.GetMD5(content);
        }
        public string UserID { get; set; }
        public string UserName { get; set; }
        public string ScheduleJobGroup { get; set; }
    }
}
